#!/usr/bin/env bash

echo "start to prepare line limit env"
chmod +x /root/repo/ci-repos/.common_scripts/common.sh
source /root/repo/ci-repos/.common_scripts/common.sh
set_gitee_hosts
prepare_git $1 $2

cur_path=$(pwd)
repo_path=${REPO_PATH}

if test -z "$repo_path"; then
    repo_path="/root/repo/"
fi

if [ ${repo_path} != ${cur_path} ]; then
    cd ${repo_path}
fi

python3 "${repo_path}ci-repos/.common_scripts/line_limit_checker.py"
exit_code=$?

if [ ${repo_path} != ${cur_path} ]; then
    cd ${cur_path}
fi

if [ ${exit_code} -ne 0 ]; then
    exit 1
fi
